Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Aggregate function</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Aggregate_function"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Aggregate_function rootpage-Aggregate_function skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Aggregate function</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p>In <a href="Database" title="Database">database management</a>, an <b>aggregate function</b> or <b>aggregation function</b> is a <a href="Function_(mathematics)" title="Function (mathematics)">function</a> where multiple values are processed together to form a single <a href="Summary_statistic" class="mw-redirect" title="Summary statistic">summary statistic</a>.
</p>

<p>Common aggregate functions include:
</p>
<ul><li><a href="Average" title="Average">Average</a> (i.e., <a href="Arithmetic_mean" title="Arithmetic mean">arithmetic mean</a>)</li>
<li><a href="Counting" title="Counting">Count</a></li>
<li><a href="Maximum" class="mw-redirect" title="Maximum">Maximum</a></li>
<li><a href="Median" title="Median">Median</a></li>
<li><a href="Minimum" class="mw-redirect" title="Minimum">Minimum</a></li>
<li><a href="Mode_(statistics)" title="Mode (statistics)">Mode</a></li>
<li><a href="Range_(statistics)" title="Range (statistics)">Range</a></li>
<li><a href="Summation" title="Summation">Sum</a></li></ul>
<p>Others include:
</p>
<ul><li>Nanmean (mean ignoring NaN values, also known as "nil" or "null")</li>
<li><a href="Standard_deviation" title="Standard deviation">Stddev</a></li></ul>
<p>Formally, an aggregate function takes as input a <a href="Set_(computer_science)" class="mw-redirect" title="Set (computer science)">set</a>, a <a href="Multiset_(abstract_data_type)" class="mw-redirect" title="Multiset (abstract data type)">multiset</a> (bag), or a <a href="List_(computing)" class="mw-redirect" title="List (computing)">list</a> from some input domain <span class="texhtml mvar" style="font-style:italic;"><i>I</i></span> and outputs an element of an output domain <span class="texhtml mvar" style="font-style:italic;"><i>O</i></span>.<sup id="cite_ref-FOOTNOTEJesusBaqueroAlmeida20112_Problem_Definition,_pp._3_1-0" class="reference"><a href="#cite_note-FOOTNOTEJesusBaqueroAlmeida20112_Problem_Definition,_pp._3-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> The input and output domains may be the same, such as for <code>SUM</code>, or may be different, such as for <code>COUNT</code>.
</p><p>Aggregate functions occur commonly in numerous <a href="Programming_language" title="Programming language">programming languages</a>, in <a href="Spreadsheet" title="Spreadsheet">spreadsheets</a>, and in <a href="Relational_algebra" title="Relational algebra">relational algebra</a>.
</p><p>The <code>listagg</code> function, as defined in the <a href="SQL%3A2016" title="SQL:2016">SQL:2016</a> standard<sup id="cite_ref-:0_2-0" class="reference"><a href="#cite_note-:0-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>
aggregates data from multiple rows into a single concatenated string.
</p><p>In the <a href="Entity%E2%80%93relationship_model" title="Entity–relationship model">entity relationship diagram</a>, aggregation is represented as seen in Figure 1 with a rectangle around the relationship and its entities to indicate that it is being treated as an aggregate entity.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Decomposable_aggregate_functions">Decomposable aggregate functions</h2></div>
<p>Aggregate functions present a <a href="Bottleneck_(software)" title="Bottleneck (software)">bottleneck</a>, because they potentially require having all input values at once. In <a href="Distributed_computing" title="Distributed computing">distributed computing</a>, it is desirable to divide such computations into smaller pieces, and distribute the work, usually <a href="Parallel_computing" title="Parallel computing">computing in parallel</a>, via a <a href="Divide_and_conquer_algorithm" class="mw-redirect" title="Divide and conquer algorithm">divide and conquer algorithm</a>.
</p><p>Some aggregate functions can be computed by computing the aggregate for subsets, and then aggregating these aggregates; examples include <code>COUNT</code>, <code>MAX</code>, <code>MIN</code>, and <code>SUM</code>. In other cases the aggregate can be computed by computing auxiliary numbers for subsets, aggregating these auxiliary numbers, and finally computing the overall number at the end; examples include <code>AVERAGE</code> (tracking sum and count, dividing at the end) and <code>RANGE</code> (tracking max and min, subtracting at the end). In other cases the aggregate cannot be computed without analyzing the entire set at once, though in some cases approximations can be distributed; examples include <code>DISTINCT COUNT</code> (<a href="Count-distinct_problem" title="Count-distinct problem">Count-distinct problem</a>), <code>MEDIAN</code>, and <code>MODE</code>.
</p><p>Such functions are called <b>decomposable aggregation functions</b><sup id="cite_ref-FOOTNOTEJesusBaqueroAlmeida20112.1_Decomposable_functions,_pp._3–4_4-0" class="reference"><a href="#cite_note-FOOTNOTEJesusBaqueroAlmeida20112.1_Decomposable_functions,_pp._3–4-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> or <b>decomposable aggregate functions</b>. The simplest may be referred to as <b>self-decomposable aggregation functions</b>, which are defined as those functions <span class="texhtml mvar" style="font-style:italic;"><i>f</i></span> such that there is a <i>merge operator</i> <span class="nowrap">⁠<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \diamond }">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo>⋄<!-- ⋄ --></mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \diamond }</annotation>
</semantics>
</math></span><img src="./10679927dffddc1b081b1af6eab8644a90391a69.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: 0.026ex; margin-bottom: -0.197ex; width:1.162ex; height:1.509ex;" alt="{\displaystyle \diamond }" loading="lazy"></span>⁠</span> such that
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle f(X\uplus Y)=f(X)\diamond f(Y)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>f</mi>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>f</mi>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>⋄<!-- ⋄ --></mo>
<mi>f</mi>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle f(X\uplus Y)=f(X)\diamond f(Y)}</annotation>
</semantics>
</math></span><img src="./ea87d37ab85fa5ca65e569b4172e983c29964e3e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:24.646ex; height:2.843ex;" alt="{\displaystyle f(X\uplus Y)=f(X)\diamond f(Y)}" loading="lazy"></span></dd></dl>
<p>where <span class="nowrap">⁠<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \uplus }">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo>⊎<!-- ⊎ --></mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \uplus }</annotation>
</semantics>
</math></span><img src="./1dd23bfcafcbbe1cf39aade17a710657a9f54e73.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.55ex; height:2.009ex;" alt="{\displaystyle \uplus }" loading="lazy"></span>⁠</span> is the union of multisets (see <a href="Monoid_homomorphism" class="mw-redirect" title="Monoid homomorphism">monoid homomorphism</a>).
</p><p>For example, <code>SUM</code>:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {SUM} ({x})=x}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>x</mi>
</mrow>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>x</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {SUM} ({x})=x}</annotation>
</semantics>
</math></span><img src="./eee00edb66051238abb6115fbd1544a96c544a6f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:12.734ex; height:2.843ex;" alt="{\displaystyle \operatorname {SUM} ({x})=x}" loading="lazy"></span>, for a singleton;</dd>
<dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {SUM} (X\uplus Y)=\operatorname {SUM} (X)+\operatorname {SUM} (Y)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {SUM} (X\uplus Y)=\operatorname {SUM} (X)+\operatorname {SUM} (Y)}</annotation>
</semantics>
</math></span><img src="./34e27cc8304cb9bafd19eb4a4420b89cb099bae7.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:36.956ex; height:2.843ex;" alt="{\displaystyle \operatorname {SUM} (X\uplus Y)=\operatorname {SUM} (X)+\operatorname {SUM} (Y)}" loading="lazy"></span>, meaning that merge <span class="nowrap">⁠<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \diamond }">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo>⋄<!-- ⋄ --></mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \diamond }</annotation>
</semantics>
</math></span><img src="./10679927dffddc1b081b1af6eab8644a90391a69.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: 0.026ex; margin-bottom: -0.197ex; width:1.162ex; height:1.509ex;" alt="{\displaystyle \diamond }" loading="lazy"></span>⁠</span> is simply addition.</dd></dl>
<p><code>COUNT</code>:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {COUNT} ({x})=1}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>x</mi>
</mrow>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mn>1</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {COUNT} ({x})=1}</annotation>
</semantics>
</math></span><img src="./e1d9f1d83bbcf3892639c2c39ca08c526530b2a5.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:16.05ex; height:2.843ex;" alt="{\displaystyle \operatorname {COUNT} ({x})=1}" loading="lazy"></span>,</dd>
<dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {COUNT} (X\uplus Y)=\operatorname {COUNT} (X)+\operatorname {COUNT} (Y)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {COUNT} (X\uplus Y)=\operatorname {COUNT} (X)+\operatorname {COUNT} (Y)}</annotation>
</semantics>
</math></span><img src="./4e71863e6bff8ac6d72c8516bfb6bc8397a4d40a.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:47.407ex; height:2.843ex;" alt="{\displaystyle \operatorname {COUNT} (X\uplus Y)=\operatorname {COUNT} (X)+\operatorname {COUNT} (Y)}" loading="lazy"></span>.</dd></dl>
<p><code>MAX</code>:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {MAX} ({x})=x}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>MAX</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>x</mi>
</mrow>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>x</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {MAX} ({x})=x}</annotation>
</semantics>
</math></span><img src="./71f3a254fb7c6707b9d518807a9b4599924f176e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.184ex; height:2.843ex;" alt="{\displaystyle \operatorname {MAX} ({x})=x}" loading="lazy"></span>,</dd>
<dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {MAX} (X\uplus Y)=\max {\bigl (}\operatorname {MAX} (X),\operatorname {MAX} (Y){\bigr )}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>MAX</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mo movablelimits="true" form="prefix">max</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="1.2em" minsize="1.2em">(</mo>
</mrow>
</mrow>
<mi>MAX</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>,</mo>
<mi>MAX</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="1.2em" minsize="1.2em">)</mo>
</mrow>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {MAX} (X\uplus Y)=\max {\bigl (}\operatorname {MAX} (X),\operatorname {MAX} (Y){\bigr )}}</annotation>
</semantics>
</math></span><img src="./7941ac46fcc340813429e4b1bd0f23afd4343d19.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:43.731ex; height:3.176ex;" alt="{\displaystyle \operatorname {MAX} (X\uplus Y)=\max {\bigl (}\operatorname {MAX} (X),\operatorname {MAX} (Y){\bigr )}}" loading="lazy"></span>.</dd></dl>
<p><code>MIN</code>:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\textstyle \operatorname {MIN} ({x})=x}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="false" scriptlevel="0">
<mi>MIN</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>x</mi>
</mrow>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>x</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\textstyle \operatorname {MIN} ({x})=x}</annotation>
</semantics>
</math></span><img src="./d5bb3a209d451fd1b88384f208024651edd8636e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:12.281ex; height:2.843ex;" alt="{\textstyle \operatorname {MIN} ({x})=x}" loading="lazy"></span>,<sup id="cite_ref-:0_2-1" class="reference"><a href="#cite_note-:0-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup></dd>
<dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {MIN} (X\uplus Y)=\min {\bigl (}\operatorname {MIN} (X),\operatorname {MIN} (Y){\bigr )}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>MIN</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mo movablelimits="true" form="prefix">min</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="1.2em" minsize="1.2em">(</mo>
</mrow>
</mrow>
<mi>MIN</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>,</mo>
<mi>MIN</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="1.2em" minsize="1.2em">)</mo>
</mrow>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {MIN} (X\uplus Y)=\min {\bigl (}\operatorname {MIN} (X),\operatorname {MIN} (Y){\bigr )}}</annotation>
</semantics>
</math></span><img src="./82fd6124939ceb46099bd49e8a8de1bcae923612.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:40.57ex; height:3.176ex;" alt="{\displaystyle \operatorname {MIN} (X\uplus Y)=\min {\bigl (}\operatorname {MIN} (X),\operatorname {MIN} (Y){\bigr )}}" loading="lazy"></span>.</dd></dl>
<p>Note that self-decomposable aggregation functions can be combined (formally, taking the product) by applying them separately, so for instance one can compute both the <code>SUM</code> and <code>COUNT</code> at the same time, by tracking two numbers.
</p><p>More generally, one can define a <b>decomposable aggregation function</b> <span class="texhtml mvar" style="font-style:italic;"><i>f</i></span> as one that can be expressed as the composition of a final function <span class="texhtml mvar" style="font-style:italic;"><i>g</i></span> and a self-decomposable aggregation function <span class="texhtml mvar" style="font-style:italic;"><i>h</i></span>, <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle f=g\circ h,f(X)=g(h(X))}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>f</mi>
<mo>=</mo>
<mi>g</mi>
<mo>∘<!-- ∘ --></mo>
<mi>h</mi>
<mo>,</mo>
<mi>f</mi>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>g</mi>
<mo stretchy="false">(</mo>
<mi>h</mi>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle f=g\circ h,f(X)=g(h(X))}</annotation>
</semantics>
</math></span><img src="./372462d9c354d1c7bba0d3ac2b3ea5b39dcf0dad.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:26.281ex; height:2.843ex;" alt="{\displaystyle f=g\circ h,f(X)=g(h(X))}" loading="lazy"></span>. For example, <code>AVERAGE</code>=<code>SUM</code>/<code>COUNT</code> and <code>RANGE</code>=<code>MAX</code>−<code>MIN</code>.
</p><p>In the <a href="MapReduce" title="MapReduce">MapReduce</a> framework, these steps are known as InitialReduce (value on individual record/singleton set), Combine (binary merge on two aggregations), and FinalReduce (final function on auxiliary values),<sup id="cite_ref-FOOTNOTEYuGundaIsard20092._Distributed_Aggregation,_pp._2–4_5-0" class="reference"><a href="#cite_note-FOOTNOTEYuGundaIsard20092._Distributed_Aggregation,_pp._2–4-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> and moving decomposable aggregation before the Shuffle phase is known as an InitialReduce step,<sup id="cite_ref-FOOTNOTEYuGundaIsard20092._Distributed_Aggregation,_p._1_6-0" class="reference"><a href="#cite_note-FOOTNOTEYuGundaIsard20092._Distributed_Aggregation,_p._1-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>
</p><p>Decomposable aggregation functions are important in <a href="Online_analytical_processing" title="Online analytical processing">online analytical processing</a> (OLAP), as they allow aggregation queries to be computed on the pre-computed results in the <a href="OLAP_cube" title="OLAP cube">OLAP cube</a>, rather than on the base data.<sup id="cite_ref-FOOTNOTEZhang20171_7-0" class="reference"><a href="#cite_note-FOOTNOTEZhang20171-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> For example, it is easy to support <code>COUNT</code>, <code>MAX</code>, <code>MIN</code>, and <code>SUM</code> in OLAP, since these can be computed for each cell of the OLAP cube and then summarized ("rolled up"), but it is difficult to support <code>MEDIAN</code>, as that must be computed for every view separately.
</p>
<div class="mw-heading mw-heading2"><h2 id="Other_decomposable_aggregate_functions">Other decomposable aggregate functions</h2></div>
<p>In order to calculate the average and standard deviation from aggregate data, it is necessary to have available for each group: the total of values (Σx<sub>i</sub> = SUM(x)), the number of values (N=COUNT(x)) and the total of squares of the values (Σx<sub>i</sub><sup>2</sup>=SUM(x<sup>2</sup>)) of each groups.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup><br>
<br>
<code>AVG</code>:
<span class="mwe-math-element mwe-math-element-block"><span class="mwe-math-mathml-display mwe-math-mathml-a11y" style="display: none;"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {AVG} (X\uplus Y)={\bigl (}\operatorname {AVG} (X)*\operatorname {COUNT} (X)+\operatorname {AVG} (Y)*\operatorname {COUNT} (Y){\bigr )}/{\bigl (}\operatorname {COUNT} (X)+\operatorname {COUNT} (Y){\bigr )}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>AVG</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="1.2em" minsize="1.2em">(</mo>
</mrow>
</mrow>
<mi>AVG</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>∗<!-- ∗ --></mo>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>AVG</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>∗<!-- ∗ --></mo>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="1.2em" minsize="1.2em">)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="1.2em" minsize="1.2em">(</mo>
</mrow>
</mrow>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="1.2em" minsize="1.2em">)</mo>
</mrow>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {AVG} (X\uplus Y)={\bigl (}\operatorname {AVG} (X)*\operatorname {COUNT} (X)+\operatorname {AVG} (Y)*\operatorname {COUNT} (Y){\bigr )}/{\bigl (}\operatorname {COUNT} (X)+\operatorname {COUNT} (Y){\bigr )}}</annotation>
</semantics>
</math></span></span>
or<br>
<span class="mwe-math-element mwe-math-element-block"><span class="mwe-math-mathml-display mwe-math-mathml-a11y" style="display: none;"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {AVG} (X\uplus Y)={\bigl (}\operatorname {SUM} (X)+\operatorname {SUM} (Y){\bigr )}/{\bigl (}\operatorname {COUNT} (X)+\operatorname {COUNT} (Y){\bigr )}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>AVG</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="1.2em" minsize="1.2em">(</mo>
</mrow>
</mrow>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="1.2em" minsize="1.2em">)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="1.2em" minsize="1.2em">(</mo>
</mrow>
</mrow>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="1.2em" minsize="1.2em">)</mo>
</mrow>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {AVG} (X\uplus Y)={\bigl (}\operatorname {SUM} (X)+\operatorname {SUM} (Y){\bigr )}/{\bigl (}\operatorname {COUNT} (X)+\operatorname {COUNT} (Y){\bigr )}}</annotation>
</semantics>
</math></span></span>
or, only if COUNT(X)=COUNT(Y)<br>
<span class="mwe-math-element mwe-math-element-block"><span class="mwe-math-mathml-display mwe-math-mathml-a11y" style="display: none;"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {AVG} (X\uplus Y)={\bigl (}\operatorname {AVG} (X)+\operatorname {AVG} (Y){\bigr )}/2}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>AVG</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="1.2em" minsize="1.2em">(</mo>
</mrow>
</mrow>
<mi>AVG</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>AVG</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="1.2em" minsize="1.2em">)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mn>2</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {AVG} (X\uplus Y)={\bigl (}\operatorname {AVG} (X)+\operatorname {AVG} (Y){\bigr )}/2}</annotation>
</semantics>
</math></span></span>
<br>
<code>SUM(x<sup>2</sup>)</code>:
The sum of squares of the values is important in order to calculate the Standard Deviation of groups<br>
<span class="mwe-math-element mwe-math-element-block"><span class="mwe-math-mathml-display mwe-math-mathml-a11y" style="display: none;"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {SUM} (X^{2}\uplus Y^{2})=\operatorname {SUM} (X^{2})+\operatorname {SUM} (Y^{2})}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<msup>
<mi>X</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo>⊎<!-- ⊎ --></mo>
<msup>
<mi>Y</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<msup>
<mi>X</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<msup>
<mi>Y</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {SUM} (X^{2}\uplus Y^{2})=\operatorname {SUM} (X^{2})+\operatorname {SUM} (Y^{2})}</annotation>
</semantics>
</math></span></span>
<br>
<code>STDDEV</code>:<br>
For a finite population with equal probabilities at all points, we have<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
<span class="mwe-math-element mwe-math-element-block"><span class="mwe-math-mathml-display mwe-math-mathml-a11y" style="display: none;"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {STDDEV} (X)=s(x)={\sqrt {{\frac {1}{N}}\sum _{i=1}^{N}(x_{i}-{\overline {x}})^{2}}}={\sqrt {{\frac {1}{N}}\left(\sum _{i=1}^{N}x_{i}^{2}\right)-({\overline {x}})^{2}}}={\sqrt {\operatorname {SUM} (x^{2})/\operatorname {COUNT} (x)-\operatorname {AVG} (x)^{2}}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>STDDEV</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>s</mi>
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<msqrt>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mi>N</mi>
</mfrac>
</mrow>
<munderover>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</munderover>
<mo stretchy="false">(</mo>
<msub>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
<mo>−<!-- − --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mover>
<mi>x</mi>
<mo accent="false">¯<!-- ¯ --></mo>
</mover>
</mrow>
<msup>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</msqrt>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<msqrt>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mi>N</mi>
</mfrac>
</mrow>
<mrow>
<mo>(</mo>
<mrow>
<munderover>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</munderover>
<msubsup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msubsup>
</mrow>
<mo>)</mo>
</mrow>
<mo>−<!-- − --></mo>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mover>
<mi>x</mi>
<mo accent="false">¯<!-- ¯ --></mo>
</mover>
</mrow>
<msup>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</msqrt>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<msqrt>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
<mo>−<!-- − --></mo>
<mi>AVG</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>x</mi>
<msup>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</msqrt>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {STDDEV} (X)=s(x)={\sqrt {{\frac {1}{N}}\sum _{i=1}^{N}(x_{i}-{\overline {x}})^{2}}}={\sqrt {{\frac {1}{N}}\left(\sum _{i=1}^{N}x_{i}^{2}\right)-({\overline {x}})^{2}}}={\sqrt {\operatorname {SUM} (x^{2})/\operatorname {COUNT} (x)-\operatorname {AVG} (x)^{2}}}}</annotation>
</semantics>
</math></span></span>
</p><p>This means that the standard deviation is equal to the square root of the difference between the average of the squares of the values and the square of the average value.
<span class="mwe-math-element mwe-math-element-block"><span class="mwe-math-mathml-display mwe-math-mathml-a11y" style="display: none;"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {STDDEV} (X\uplus Y)={\sqrt {\operatorname {SUM} (X^{2}\uplus Y^{2})/\operatorname {COUNT} (X\uplus Y)-\operatorname {AVG} (X\uplus Y)^{2}}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>STDDEV</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<msqrt>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<msup>
<mi>X</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo>⊎<!-- ⊎ --></mo>
<msup>
<mi>Y</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>−<!-- − --></mo>
<mi>AVG</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<msup>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</msqrt>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {STDDEV} (X\uplus Y)={\sqrt {\operatorname {SUM} (X^{2}\uplus Y^{2})/\operatorname {COUNT} (X\uplus Y)-\operatorname {AVG} (X\uplus Y)^{2}}}}</annotation>
</semantics>
</math></span></span>
<span class="mwe-math-element mwe-math-element-block"><span class="mwe-math-mathml-display mwe-math-mathml-a11y" style="display: none;"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {STDDEV} (X\uplus Y)={\sqrt {{\bigl (}\operatorname {SUM} (X^{2})+\operatorname {SUM} (Y^{2}){\bigr )}/{\bigl (}\operatorname {COUNT} (X)+\operatorname {COUNT} (Y){\bigr )}-{\bigl (}(\operatorname {SUM} (X)+\operatorname {SUM} (Y))/(\operatorname {COUNT} (X)+\operatorname {COUNT} (Y)){\bigr )}^{2}}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>STDDEV</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo>⊎<!-- ⊎ --></mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<msqrt>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="1.2em" minsize="1.2em">(</mo>
</mrow>
</mrow>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<msup>
<mi>X</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<msup>
<mi>Y</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="1.2em" minsize="1.2em">)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="1.2em" minsize="1.2em">(</mo>
</mrow>
</mrow>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="1.2em" minsize="1.2em">)</mo>
</mrow>
</mrow>
<mo>−<!-- − --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="1.2em" minsize="1.2em">(</mo>
</mrow>
</mrow>
<mo stretchy="false">(</mo>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>SUM</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mo stretchy="false">(</mo>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>X</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi>COUNT</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo stretchy="false">(</mo>
<mi>Y</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">)</mo>
<msup>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="1.2em" minsize="1.2em">)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</msqrt>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {STDDEV} (X\uplus Y)={\sqrt {{\bigl (}\operatorname {SUM} (X^{2})+\operatorname {SUM} (Y^{2}){\bigr )}/{\bigl (}\operatorname {COUNT} (X)+\operatorname {COUNT} (Y){\bigr )}-{\bigl (}(\operatorname {SUM} (X)+\operatorname {SUM} (Y))/(\operatorname {COUNT} (X)+\operatorname {COUNT} (Y)){\bigr )}^{2}}}}</annotation>
</semantics>
</math></span></span>
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Cross-tabulation" class="mw-redirect" title="Cross-tabulation">Cross-tabulation</a> a.k.a. <a href="Contingency_table" title="Contingency table">Contingency table</a></li>
<li><a href="Data_drilling" title="Data drilling">Data drilling</a></li>
<li><a href="Data_mining" title="Data mining">Data mining</a></li>
<li><a href="Data_processing" title="Data processing">Data processing</a></li>
<li><a href="Extract%2C_transform%2C_load" title="Extract, transform, load">Extract, transform, load</a></li>
<li><a href="Fold_(higher-order_function)" title="Fold (higher-order function)">Fold (higher-order function)</a></li>
<li><a href="Group_by_(SQL)" title="Group by (SQL)">Group by (SQL)</a>, SQL clause</li>
<li><a href="OLAP_cube" title="OLAP cube">OLAP cube</a></li>
<li><a href="Online_analytical_processing" title="Online analytical processing">Online analytical processing</a></li>
<li><a href="Pivot_table" title="Pivot table">Pivot table</a></li>
<li><a href="Relational_algebra" title="Relational algebra">Relational algebra</a></li>
<li><a href="Utility_functions_on_indivisible_goods#Aggregates_of_utility_functions" title="Utility functions on indivisible goods">Utility functions on indivisible goods#Aggregates of utility functions</a></li>
<li><a href="XML_for_Analysis" title="XML for Analysis">XML for Analysis</a></li>
<li><a href="AggregateIQ" title="AggregateIQ">AggregateIQ</a></li>
<li><a href="MapReduce" title="MapReduce">MapReduce</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-FOOTNOTEJesusBaqueroAlmeida20112_Problem_Definition,_pp._3-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEJesusBaqueroAlmeida20112_Problem_Definition,_pp._3_1-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFJesusBaqueroAlmeida2011">Jesus, Baquero &amp; Almeida 2011</a>, 2 Problem Definition, pp. 3.</span>
</li>
<li id="cite_note-:0-2"><span class="mw-cite-backlink">^ <a href="#cite_ref-:0_2-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-:0_2-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFWinand2017" class="citation web cs1">Winand, Markus (2017-05-15). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170527080053/https://dzone.com/articles/big-news-in-databases-new-sql-standard-cloud-wars">"Big News in Databases: New SQL Standard, Cloud Wars, and ACIDRain (Spring 2017)"</a>. DZone. Archived from <a rel="nofollow" class="external text" href="https://dzone.com/articles/big-news-in-databases-new-sql-standard-cloud-wars">the original</a> on 2017-05-27<span class="reference-accessdate">. Retrieved <span class="nowrap">2017-06-10</span></span>. <q>In December 2016, ISO released a new version of the SQL standard. It introduces new features such as row pattern matching, listagg, date and time formatting, and JSON support.</q></cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite id="CITEREFElmasri2016" class="citation book cs1">Elmasri, Ramez (2016). <i>Fundamentals of database systems</i>. Sham Navathe (Seventh&nbsp;ed.). Hoboken, NJ. p.&nbsp;133. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-13-397077-7</bdi>. <a href="OCLC_(identifier)" class="mw-redirect" title="OCLC (identifier)">OCLC</a>&nbsp;<a rel="nofollow" class="external text" href="https://search.worldcat.org/oclc/913842106">913842106</a>.</cite><span class="cs1-maint citation-comment"><code class="cs1-code">{{cite book}}</code>: CS1 maint: location missing publisher (link)</span></span>
</li>
<li id="cite_note-FOOTNOTEJesusBaqueroAlmeida20112.1_Decomposable_functions,_pp._3–4-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEJesusBaqueroAlmeida20112.1_Decomposable_functions,_pp._3–4_4-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFJesusBaqueroAlmeida2011">Jesus, Baquero &amp; Almeida 2011</a>, 2.1 Decomposable functions, pp. 3–4.</span>
</li>
<li id="cite_note-FOOTNOTEYuGundaIsard20092._Distributed_Aggregation,_pp._2–4-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEYuGundaIsard20092._Distributed_Aggregation,_pp._2–4_5-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFYuGundaIsard2009">Yu, Gunda &amp; Isard 2009</a>, 2. Distributed Aggregation, pp. 2–4.</span>
</li>
<li id="cite_note-FOOTNOTEYuGundaIsard20092._Distributed_Aggregation,_p._1-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEYuGundaIsard20092._Distributed_Aggregation,_p._1_6-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFYuGundaIsard2009">Yu, Gunda &amp; Isard 2009</a>, 2. Distributed Aggregation, p. 1.</span>
</li>
<li id="cite_note-FOOTNOTEZhang20171-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEZhang20171_7-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFZhang2017">Zhang 2017</a>, p.&nbsp;1.</span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text">Ing. Óscar Bonilla, MBA</span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><a href="Standard_deviation#Identities_and_mathematical_properties" title="Standard deviation">Standard deviation#Identities and mathematical properties</a></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="Literature">Literature</h2></div>
<ul><li><cite id="CITEREFGrabischMarichalMesiarPap2009" class="citation book cs1">Grabisch, Michel; Marichal, Jean-Luc; Mesiar, Radko; Pap, Endre (2009). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/aggregationfunct0000unse"><i>Aggregation functions</i></a></span>. Encyclopedia of Mathematics and its Applications. Vol.&nbsp;127. Cambridge: <a href="Cambridge_University_Press" title="Cambridge University Press">Cambridge University Press</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-521-51926-7</bdi>. <a href="Zbl_(identifier)" class="mw-redirect" title="Zbl (identifier)">Zbl</a>&nbsp;<a rel="nofollow" class="external text" href="https://zbmath.org/?format=complete&amp;q=an:1196.00002">1196.00002</a>.</cite></li>
<li><a rel="nofollow" class="external text" href="https://oracletutorial.net/aggregate-functions.html">Oracle Aggregate Functions: MAX, MIN, COUNT, SUM, AVG Examples</a></li></ul>
<style data-mw-deduplicate="TemplateStyles:r1239549316">
/* start https://en.wikipedia.org/ */


.mw-parser-output .refbegin{margin-bottom:0.5em}.mw-parser-output .refbegin-hanging-indents>ul{margin-left:0}.mw-parser-output .refbegin-hanging-indents>ul>li{margin-left:0;padding-left:3.2em;text-indent:-3.2em}.mw-parser-output .refbegin-hanging-indents ul,.mw-parser-output .refbegin-hanging-indents ul li{list-style:none}@media(max-width:720px){.mw-parser-output .refbegin-hanging-indents>ul>li{padding-left:1.6em;text-indent:-1.6em}}.mw-parser-output .refbegin-columns{margin-top:0.3em}.mw-parser-output .refbegin-columns ul{margin-top:0}.mw-parser-output .refbegin-columns li{page-break-inside:avoid;break-inside:avoid-column}@media screen{.mw-parser-output .refbegin{font-size:90%}}


/* end https://en.wikipedia.org/ */
</style><div class="refbegin" style="">
<ul><li><cite id="CITEREFYuGundaIsard2009" class="citation conference cs1">Yu, Yuan; Gunda, Pradeep Kumar; Isard, Michael (2009). <span class="id-lock-subscription" title="Paid subscription required"><a rel="nofollow" class="external text" href="https://www.microsoft.com/en-us/research/publication/distributed-aggregation-for-data-parallel-computing-interfaces-and-implementations/"><i>Distributed aggregation for data-parallel computing: interfaces and implementations</i></a></span>. ACM SIGOPS 22nd symposium on Operating systems principles. <a href="Association_for_Computing_Machinery" title="Association for Computing Machinery">ACM</a>. pp.&nbsp;<span class="nowrap">247–</span>260. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F1629575.1629600">10.1145/1629575.1629600</a>.</cite></li>
<li><cite id="CITEREFJesusBaqueroAlmeida2011" class="citation arxiv cs1">Jesus, Paulo; Baquero, Carlos; Almeida, Paulo Sérgio (2011). "A Survey of Distributed Data Aggregation Algorithms". <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1110.0725">1110.0725</a></span> [<a rel="nofollow" class="external text" href="https://arxiv.org/archive/cs.DC">cs.DC</a>].</cite></li>
<li><cite id="CITEREFZhang2017" class="citation techreport cs1">Zhang, Chao (2017). <a rel="nofollow" class="external text" href="https://hal.archives-ouvertes.fr/hal-01533675/"><i>Symmetric and Asymmetric Aggregate Function in Massively Parallel Computing</i></a> (Technical report).</cite></li></ul>
</div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="https://msdn.microsoft.com/en-IN/library/ms173454.aspx">Aggregate Functions (Transact-SQL)</a></li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-23" href="https://en.wikipedia.org/wiki/?title=Aggregate_function&amp;oldid=1302168101">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>